<template>
<h1>双向绑定指令</h1>
  <input type="text" v-model="info">
  {{info}}
  <hr>
  <input type="text" name="username" placeholder="请输入用户名" v-model="user.username">
  <input type="password" name="username" placeholder="请输入密码" v-model="user.password">
  <input type="radio" name="gender" v-model="user.gender" value="1">男
  <input type="radio" name="gender" v-model="user.gender" value="0">女
  <button @click="reg">注册</button>
</template>
<script setup>

import {ref} from "vue";

const info = ref('12')
/*响应式变量user,使用时使用.value*/
const user = ref({
  username:'',
  password:'',
  gender:''
})
const reg = ()=>{
  console.log(user);
  console.log(user.value);
  console.log(user.value.username);
  console.log(user.value.password);
  console.log(user.value.gender);
}
</script>


<style scoped>

</style>